package com.wnnight.wys.entity.lanlord;

import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.wnnight.wys.entity.car.Car;
import com.wnnight.wys.entity.car.Park;
import com.wnnight.wys.entity.room.Room;
import com.wnnight.wys.groupInterface.AddGroup;
import com.wnnight.wys.groupInterface.AlterGroup;
import com.wnnight.wys.groupInterface.RealNameGroup;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import javax.validation.constraints.*;
import java.util.List;

/**
 * @author Mr.Wang
 * @ClassName: Landlord
 * @Description: 业主实体类
 * @date: 2022/8/27-17:07
 */
@Getter
@Setter
@ToString
@TableName(value = "landlord", keepGlobalPrefix = true)
@ExcelIgnoreUnannotated
public class Landlord {
    @TableId(type = IdType.AUTO)
    @Min(groups = {AlterGroup.class},value = 1,message = "id不合法")
    @NotNull(groups = {AlterGroup.class},message = "id不能为空")
    private Integer id;
    @NotEmpty(groups = RealNameGroup.class,message = "姓名不能为空")
    @ExcelProperty(value = "姓名", index = 0)
    private String name;
    @Pattern(groups = {AlterGroup.class,RealNameGroup.class},regexp = "^$|^(?:(?:\\+|00)86)?1(?:(?:3[\\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\\d])|(?:9[189]))\\d{8}$",message = "手机号码无效")
    @NotEmpty(groups = RealNameGroup.class,message = "手机号不能为空")
    @ExcelProperty(value = "电话号码", index = 1)
    private String phone;
    @NotEmpty(groups = RealNameGroup.class,message = "性别不能为空")
    @ExcelProperty(value = "性别", index = 2)
    private String gender;
    @NotEmpty(groups = RealNameGroup.class,message = "住址不能为空")
    @ExcelProperty(value = "住址", index = 3)
    private String place;
    @TableField("id_card")
    @Pattern(groups = {AlterGroup.class,RealNameGroup.class},regexp = "^$|^[1-9]\\d{5}(?:18|19|20)\\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[1-2]\\d|30|31)\\d{3}[0-9Xx]$",message = "身份证无效")
    @NotEmpty(groups = RealNameGroup.class,message = "身份证号不能为空")
    @ExcelProperty(value = "身份证号", index = 4)
    private String idCard;
    @TableField("sub_time")
    @ExcelProperty(value = "提交时间", index = 5)
    private String subTime;
    @ExcelProperty(value = "状态", index = 6)
    private String status;
    @NotEmpty(groups = AddGroup.class,message = "账号不能为空")
    @Size(groups = {AlterGroup.class,AddGroup.class},max = 10,min = 2,message = "账号长度在2-10之间")
    @ExcelProperty(value = "用户名", index = 7)
    private String account;
    @NotEmpty(groups = AddGroup.class,message = "密码不能为空")
    @Size(groups = {AlterGroup.class,AddGroup.class},max = 20,min = 6,message = "密码长度在6-20之间")
    private String password;
    private byte[] img;

    //查询房屋信息使用
    @TableField(exist = false)
    private List<Room> rooms;
    //查询车位信息使用
    @TableField(exist = false)
    private List<Park> parks;
    //查询车辆信息使用
    @TableField(exist = false)
    private List<Car> cars;

}
